<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>分币</title>
    <style>
        #hu {
            width: 100%;
            height: 100%;
            background: url('http://103.112.28.230:8080/endless/invite/background.png')no-repeat;
            background-size: 100%100%;
        }
        
        .activity {
            width: 90%;
            border: 1px solid #ffffff;
            margin: -110px auto;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 5px 122px 0px rgba(255, 82, 81, 0.76);
            border-radius: 10px;
            position: relative;
            z-index: 999;
            padding-bottom: 40px;
        }
        
        .activity .chane {
            width: 90%;
            height: 40px;
            border: 1px solid rgba(223, 179, 121, 1);
            border-radius: 10px;
            margin: 10px auto;
            display: flex;
            justify-content: flex-start;
            align-items: center;
        }
        
        .activity .chane input {
            border: none;
            margin-left: 10px;
            outline: none;
        }
        
        .button button {
            width: 90%;
            height: 40px;
            background: rgba(255, 207, 125, 1);
            border-radius: 10px;
            margin-left: 5%;
            border: 1px solid rgba(255, 207, 125, 1);
            font-size: 0.3rem;
            font-family: PingFang-SC-Medium;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
        }
        
        .explain {
            font-size: 0.3rem;
            font-family: PingFang-SC-Medium;
            font-weight: 500;
            color: rgba(148, 38, 37, 1);
            margin: 40% auto;
            text-align: center
        }
        
        .van-radio__label {
            color: #323233;
            margin-left: 10px;
            font-size: 0.3rem;
        }
        
        .van-radio__icon .van-icon {
            /* font-size: 11px; */
            color: transparent;
            text-align: center;
            line-height: inherit;
            width: 15px;
            height: 15px;
            box-sizing: border-box;
            border: 1px solid #e5e5e5;
            -webkit-transition: .2s;
            transition: .2s;
        }
        
        .codetxt1 {
            width: 30%;
            height: 40px;
            background: rgba(255, 207, 125, 1);
            border-radius: 10px;
            border: 1px solid rgba(255, 207, 125, 1);
            font-size: 0.3rem;
            font-family: PingFang-SC-Medium;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
            margin-left: 10px;
        }
        
        option {
            width: 200px;
            height: 200px;
        }
    </style>
    <!-- <link rel="stylesheet" href="css/index.css"> -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@1.6/lib/index.css">
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@1.6/lib/vant.min.js"></script>
    <script>
        ;
        (function(win, lib) {
            var doc = win.document;
            var docEl = doc.documentElement;
            var metaEl = doc.querySelector('meta[name="viewport"]');
            var flexibleEl = doc.querySelector('meta[name="flexible"]');
            var dpr = 0;
            var scale = 0;
            var tid;
            var flexible = lib.flexible || (lib.flexible = {});

            if (metaEl) {
                console.warn('将根据已有的meta标签来设置缩放比例');
                var match = metaEl.getAttribute('content').match(/initial\-scale=([\d\.]+)/);
                if (match) {
                    scale = parseFloat(match[1]);
                    dpr = parseInt(1 / scale);
                }
            } else if (flexibleEl) {
                var content = flexibleEl.getAttribute('content');
                if (content) {
                    var initialDpr = content.match(/initial\-dpr=([\d\.]+)/);
                    var maximumDpr = content.match(/maximum\-dpr=([\d\.]+)/);
                    if (initialDpr) {
                        dpr = parseFloat(initialDpr[1]);
                        scale = parseFloat((1 / dpr).toFixed(2));
                    }
                    if (maximumDpr) {
                        dpr = parseFloat(maximumDpr[1]);
                        scale = parseFloat((1 / dpr).toFixed(2));
                    }
                }
            }

            if (!dpr && !scale) {
                var isAndroid = win.navigator.appVersion.match(/android/gi);
                var isIPhone = win.navigator.appVersion.match(/iphone/gi);
                var devicePixelRatio = win.devicePixelRatio;
                if (isIPhone) {
                    // iOS下，对于2和3的屏，用2倍的方案，其余的用1倍方案
                    if (devicePixelRatio >= 3 && (!dpr || dpr >= 3)) {
                        dpr = 3;
                    } else if (devicePixelRatio >= 2 && (!dpr || dpr >= 2)) {
                        dpr = 2;
                    } else {
                        dpr = 1;
                    }
                } else {
                    // 其他设备下，仍旧使用1倍的方案
                    dpr = 1;
                }
                scale = 1 / dpr;
            }

            docEl.setAttribute('data-dpr', dpr);
            if (!metaEl) {
                metaEl = doc.createElement('meta');
                metaEl.setAttribute('name', 'viewport');
                metaEl.setAttribute('content', 'initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' +
                    scale + ', user-scalable=no');
                if (docEl.firstElementChild) {
                    docEl.firstElementChild.appendChild(metaEl);
                } else {
                    var wrap = doc.createElement('div');
                    wrap.appendChild(metaEl);
                    doc.write(wrap.innerHTML);
                }
            }

            function refreshRem() {
                var width = docEl.getBoundingClientRect().width;
                if (width / dpr > 540) {
                    width = 540 * dpr;
                }
                var rem = width / 10;
                docEl.style.fontSize = rem + 'px';
                flexible.rem = win.rem = rem;
            }

            win.addEventListener('resize', function() {
                clearTimeout(tid);
                tid = setTimeout(refreshRem, 300);
            }, false);
            win.addEventListener('pageshow', function(e) {
                if (e.persisted) {
                    clearTimeout(tid);
                    tid = setTimeout(refreshRem, 300);
                }
            }, false);

            if (doc.readyState === 'complete') {
                doc.body.style.fontSize = 12 * dpr + 'px';
            } else {
                doc.addEventListener('DOMContentLoaded', function(e) {
                    doc.body.style.fontSize = 12 * dpr + 'px';
                }, false);
            }


            refreshRem();

            flexible.dpr = win.dpr = dpr;
            flexible.refreshRem = refreshRem;
            flexible.rem2px = function(d) {
                var val = parseFloat(d) * this.rem;
                if (typeof d === 'string' && d.match(/rem$/)) {
                    val += 'px';
                }
                return val;
            }
            flexible.px2rem = function(d) {
                var val = parseFloat(d) / this.rem;
                if (typeof d === 'string' && d.match(/px$/)) {
                    val += 'rem';
                }
                return val;
            }

        })(window, window['lib'] || (window['lib'] = {}));
    </script>

</head>

<body>
    <div id="root" :class="{show: rootShow}">
        <!-- 图片 -->
        <div id="hu">
            <img style=" width: 90%;margin:0 auto;margin-left: 7%; " src="http://103.112.28.230:8080/endless/invite/picture.png" alt=" ">
            <!-- 下面的input -->
            <div class="activity">

                <div class="chane">
                    <input style="background: none" id="input" class="codetxt" type="text" placeholder="国家地区选择" ref="countrys" disabled value>
                    <select name="">
            <option id="option" v-for="(item,index) in countryChineseName " value="">{{item.countryChineseName}}
            </option>
          </select>
                </div>
                <!-- 手机号 -->
                <div class="chane">
                    <div style="padding-left:15px;display: none">+{{areaNum}}</div>
                    <input v-model="phone" type="text" placeholder="请输入手机号码">
                </div>
                <!-- 验证码 -->
                <div style="border: none" class="chane">
                    <input style=" border-bottom: 1px solid #ebedf0;border: 1px solid rgb(223, 179, 121); border-radius: 10px;width: 65%;height: 40px;margin-top: -2px;margin-left: -1px; outline: none;text-indent: 10px; " type="number" v-model="code " value placeholder="请输入验证码"
                        maxlength="6" class="msm-code">
                    <button class="codetxt1" type="button" :disabled="disabled" @click="sendcode">{{btntxt}}</button>
                </div>
                <!-- 请设置登录密码 -->
                <div class="chane">
                    <input v-model="password" type="password" placeholder="请设置登录密码">
                    <span class="tips">{{passwordValidate.errorText}}</span>
                </div>
                <div class="chane">
                    <input type="password" v-model="passwordChecked" placeholder="请重复输入密码">
                    <span v-if="passwordChecked" class="tips">{{passwordCheckValidate.errorText}}</span>
                </div>

                <!-- 邀请码 -->
                <div v-show="false" class="chane">
                    <input id="aaaaa" v-model="getCodeNow" style="background: none" type="text" placeholder="请输入邀请码">
                </div>
                <!-- 按钮 -->
                <div class="button">
                    <button @click="reg">立即注册</button>
                </div>
                <van-radio-group v-model="radio" class="buy6-one">
                    <van-radio name="1">
                        勾选即表示您已阅读并同意我们的
                        <span style="color:#D1A568">《投资服务协议》</span>
                    </van-radio>
                </van-radio-group>
            </div>
            <!-- 本活动最终解释权归million wallet所有 -->
            <div class="explain ">本活动最终解释权归million wallet所有</div>
        </div>
    </div>

</body>
<script>
    var vm = new Vue({
        el: '#root',
        data: {

            countryChineseName: [],
            rootShow: false,
            radio: "0",
            phone: "",
            code: "",
            password: "",
            confirmPassword: "",
            passwordChecked: "",
            // yaoqCode: localStorage.getItem('yaoqCode'),
            btntxt: "获取验证码",
            disabled: false,
            time: 0,
            countrys: "",
            areaNum: "86",
            addd: window.location.href,
            getCodeNow: ''

        },
        created() {
            console.log(this.addd, 333)
            this.getCodeNow = this.addd.substring(this.addd.indexOf('=') + 1, this.addd.length)
            console.log(this.getCodeNow, 555)
                //国籍接口
            axios.get('http://103.112.28.230:8080/endless/country/list', {

            }).then(res => {
                console.log(res.data.data); //请求的返回体
                this.countryChineseName = res.data.data


            })


        },
        mounted() {

        },
        computed: {

        },

        methods: {
            //发送手机短信验证码
            sendcode() {
                let reg = /^1(3|4|5|7|8)\d{9}$/;
                if (this.phone == "") {
                    this.$toast("手机号不能为空");
                } else if (!reg.test(this.phone)) {
                    this.$toast("手机号格式不正确");
                } else {
                    this.time = 60;
                    this.disabled = true;
                    //验证码的时间设置
                    this.timer();
                    //手机号调取后端接口
                    axios.get('http://103.112.28.230:8080/endless/user/getVerificationCode', {
                            params: {
                                phoneNo: this.phone,
                                areaNo: this.areaNum
                            }
                        }).then(res => {
                            console.log(res.data);
                            if (res.status != 200) {
                                this.$toast("网络错误");
                            } else if (res.status == 200) {
                                if (res.data.error == null && res.data.result == true) {
                                    this.$toast("请注意接收验证码");
                                } else if (res.data.error != null && res.data.result == null) {
                                    this.$toast(res.data.msg);
                                }
                            }
                        })
                        .catch(function(err) {
                            console.log(err);
                        });
                }
            },
            //验证码的倒计时
            timer() {
                if (this.time > 0) {
                    this.time--;
                    this.btntxt = this.time + "s后获取";
                    setTimeout(this.timer, 1000);
                } else {
                    this.time = 0;
                    this.btntxt = "获取验证码";
                    this.disabled = false;
                }
            },
            //注册账号
            reg() {
                if (this.radio == "0") {
                    this.$toast("未同意投资服务协议！");
                    // return false;
                }



                $.ajax({
                    type: "post",
                    cache: false,
                    traditional: true,
                    dataType: "json",
                    url: 'http://103.112.28.230:8080/endless/user/register',
                    xhrFields: {
                        withCredentials: true
                    },
                    crossDomain: true,
                    data: {
                        phoneNo: this.phone,
                        verificationCode: this.code,
                        password: this.password,
                        confirmPassword: this.passwordChecked,
                        invitationCode: this.getCodeNow
                    },
                    success: function(data) {
                        console.log(data);
                        if (data.code == 230) {
                            alert(res.data.msg);
                        }
                        if (data.code == 200) {
                            // window.location.href = 'http://103.112.28.230:8080/endless/apk/endless.apk';
                            window.location.href = 'https://www.baidu.com/';

                        }

                    }
                });


            }






        },
        computed: {
            passwordValidate: function() {
                let errorText;
                if (!/^[0-9A-Za-z]{8,16}$/.test(this.password)) {
                    errorText = "密码少于8位";
                } else {
                    errorText = "";
                }
                if (!this.passwordFlag) {
                    errorText = "";
                    this.passwordFlag = true;
                }
                return {
                    errorText
                };
            },
            passwordCheckValidate: function() {
                var errorText;
                if (!/^[0-9A-Za-z]{8,16}$/.test(this.passwordChecked)) {
                    errorText = "密码少于8位";
                } else if (this.password !== this.passwordChecked) {
                    errorText = "两次密码不匹配";
                } else {
                    errorText = "";
                }
                return {
                    errorText
                };
            }
        }

    });
</script>


</html>